//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "init_server.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

MSO_GROUP_CLEANUP = [] execFSM "tmf\core\fsms\GroupCleaner.fsm";
MSO_VEHICLE_CLEANUP = ["groundWeaponHolder","WeaponHolder","WeaponHolderSimulated","WeaponHolder_Single_F","Chemlight_green","Chemlight_red","Chemlight_yellow","Chemlight_blue","CraterLong","CraterLong_small"] execFSM "tmf\core\fsms\MapCleaner.fsm";

// Converts markers to buildings
[] spawn {
	private ["_count","_missing","_marker","_type"];
	_count = 0;
	_missing = 0;
	while { _missing < 100 } do {
		_marker = format["building_%1",_count];
		if (markerShape _marker != "") then {
			_type = markerText _marker;
			if (_type != "") then {
				if (_type isKindOf "Static" || _type isKindOf "Thing") then {
					[_type,_marker] call EFUNC(create);
				} else{
					ERROR("Incompatible Type",ARR_2(_marker,_type));
				};
			};
			_missing = 0;
		} else {
			_missing = _missing + 1;
		};
		_count = _count + 1;
	};
};

// Equips pre placed units with the right equipment
{
	if (side _x != GVAR(side_own) && !(isPlayer _x) && alive _x) then {
		[_x] call FFUNC(modifyItems);
	};
} foreach allUnits;

TRACE("Executed");